import tkinter as tk
from tkinter import messagebox
window = tk.Tk()
window.title('my window')
window.geometry('400x400')


def hit_me():
    # tk.messagebox.showinfo(title='HI',message='hahahaha')#title为弹窗头信息，message为弹窗提示信息
    # tk.messagebox.showwarning(title='Hi',message="nononono")
    # tk.messagebox.showerror(title='Hi',message='No!!never')
    # a = tk.messagebox.askquestion(title='Hi',message='hahahaha')#返回'yes','no'
    # a = tk.messagebox.askyesno(title='Hi', message='hahahaha')#返回true,false
    # a = tk.messagebox.asktrycancel(title='Hi',message='hahaha')#同上
    a = tk.messagebox.askokcancel(title='hi', message='hahahah')  # 同上
    # if a==yes:  # 可以得到用户意见后再进行操作
    #  ...................


b = tk.Button(window, text='hit me', command=hit_me)
b.pack()
window.mainloop()